<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<link rel="stylesheet" href="static/css/global.css" />
	<%@ include file="../../system/main/main_top.jsp"%>
	</head>
<body>
<div class="container-fluid" id="main-container">
<div id="page-content" class="clearfix">
	<div class="row-fluid">
			<!-- 检索  -->
			<form action="favoriteMembers/list.do" method="post" name="Form" id="Form">
			<input type="hidden" name="gender" id="gender" value="${pd.gender }">
			<input type="hidden" name="age" id="age" value="${pd.age }">
			<input type="hidden" name="scanQuantity" id="scanQuantity" value="${pd.scanQuantity }">
			<div style="width: 125px; padding-right: 15px; text-align: right; line-height: 26px; display:inline-block;">目前总关注人数：</div>
			<div style="display:inline-block;">
				<i></i>
				<span><font color="#00ABFA">${pd.totalQuantity }</font></span>
			</div>
			
			<div style="margin-top: -15px; margin-bottom: -15px;"><hr></div>
			<div style="width: 125px; padding-right: 15px; text-align: right;line-height: 26px; display:inline-block;">按性别：</div>
			<div style="display:inline-block;">
				<a href="javascript:showAllDataViaGender(0);" title="全部" style="margin-right: 40px;">
					<i></i>
					<span >全部</span>
				</a>
				<a href="javascript:showAllDataViaGender(1);" title="男性" style="margin-right: 40px;">
					<i></i>
					<span >男性</span>
				</a>
				<a href="javascript:showAllDataViaGender(2);" title="女性">
					<i></i>
					<span >女性</span>
				</a>
			</div>
			<div style="margin-top: -15px; margin-bottom: -15px;"><hr></div>
			
			<div style="width: 125px; padding-right: 15px;text-align: right; line-height: 26px; display:inline-block;">按年龄：</div>
			<div style="display:inline-block;">
				<a href="javascript:showAllDataViaAge('0');" title="全部" style="margin-right: 40px;">
					<i></i>
					<span >全部</span>
				</a>
				<a href="javascript:showAllDataViaAge('15,25');" title="15-25" style="margin-right: 35px;">
					<i></i>
					<span >15-25</span>
				</a>
				<a href="javascript:showAllDataViaAge('26,35');" title="26-35" style="margin-right: 30px;">
					<i></i>
					<span >26-35</span>
				</a>	
				<a href="javascript:showAllDataViaAge('36,45');" title="36-45" style="margin-right: 40px;">
					<i></i>
					<span >36-45</span>
				</a>	
				<a href="javascript:showAllDataViaAge('45,100');" title="45以上">
					<i></i>
					<span >45以上</span>
				</a>		
			</div>
			<div style="margin-top: -15px; margin-bottom: -15px;"><hr></div>
			
			<div style="width: 125px; padding-right: 15px;text-align: right; line-height: 26px;display:inline-block;">按入场次数：</div>
			<div style="display:inline-block;">
				<a href="javascript:showAllDataViaScanQuantity('0');" title="全部" style="margin-right: 40px;">
					<i></i>
					<span >全部</span>
				</a>
				<a href="javascript:showAllDataViaScanQuantity('1,3');" title="1-3" style="margin-right: 48px;">
					<i></i>
					<span >1-3</span>
				</a>
				<a href="javascript:showAllDataViaScanQuantity('4,6');" title="4-6" style="margin-right: 44px;">
					<i></i>
					<span >4-6</span>
				</a>	
				<a href="javascript:showAllDataViaScanQuantity('6,9');" title="6-9" style="margin-right: 52px;">
					<i></i>
					<span >6-9</span>
				</a>	
				<a href="javascript:showAllDataViaScanQuantity('10,365');" title="10次以上">
					<i></i>
					<span >10次以上</span>
				</a>		
			</div>
			
			<div style="margin-top: -15px; margin-bottom: -15px;"><hr></div>
			<div style="width: 125px; padding-right: 15px;text-align: right; line-height: 26px;display:inline-block;">已选条件：</div>
			<div style="display:inline-block;">
				<c:forEach var="map" items="${searchMap}">
        			<c:if test="${map.key == 'gender' && !empty map.value}">
						<div style="width: 110px; display:inline-block;">
							<span style="color:#ff7700;">性别：</span>
							<c:forEach var="genderMap" items="${map.value}">
							<a href="javascript:showAllDataViaGender(-1);" style="color:#ff7700;">
								<em>${genderMap.value}</em>&nbsp;&nbsp;
								<b style="background:url(<%=basePath%>static/img/icon.png) no-repeat;background-position: 0 -186px; margin-top: 25px;" title="关闭">&nbsp;&nbsp;&nbsp;&nbsp;</b>
							</a>
							</c:forEach>
						</div>
					</c:if>
					<c:if test="${map.key == 'age' && !empty map.value}">
						<div style="width: 150px; display:inline-block;">
							<span style="color:#ff7700;">年龄：</span>
							<c:forEach var="ageMap" items="${map.value}">
							<a href="javascript:showAllDataViaAge(-1);" style="color:#ff7700;">
								<em>${ageMap.value}</em>&nbsp;&nbsp;
								<b style="background:url(<%=basePath%>static/img/icon.png) no-repeat;background-position: 0 -186px; margin-top: 25px;" title="关闭">&nbsp;&nbsp;&nbsp;&nbsp;</b>
							</a>
							</c:forEach>
						</div>
					</c:if>
					<c:if test="${map.key == 'scanQuantity' && !empty map.value}">
						<div style="width: 130px;display:inline-block; ">
							<span style="color:#ff7700;">入场次数：</span>
							<c:forEach var="scanQuantityMap" items="${map.value}">
							<a href="javascript:showAllDataViaScanQuantity(-1);" style="color:#ff7700;">
								<em>${scanQuantityMap.value}</em>&nbsp;&nbsp;
								<b style="background:url(<%=basePath%>static/img/icon.png) no-repeat;background-position: 0 -186px; margin-top: 25px;" title="关闭">&nbsp;&nbsp;&nbsp;&nbsp;</b>
							</a>
							</c:forEach>
						</div>
					</c:if>
				</c:forEach>
			</div>
			<div style="margin-top: -15px; margin-bottom: -15px;"><hr></div>
			<!-- 检索  -->
		
			<table id="table_report" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th class="center"><label><input type="checkbox"
											id="zcheckbox" /><span class="lbl"></span></label></th>
						<th>用户名</th>
						<th>手机号码</th>
						<th>性别</th>
						<th>年龄</th>
						<th>入场次数</th>
						<th>初次关注时间</th>
						<th>关注状态</th>
					</tr>
				</thead>
										
				<tbody>
					
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
									<td class='center' style="width: 30px;"><label><input
														type='checkbox' name='ids' value="${var.m_id }"
														id="${var.m_id }" alt="${var.username }" /><span
														class="lbl"></span></label></td>
									<td>${var.username}</td>
									<td>${var.mobile}</td>
									<td>
										<c:choose>
											<c:when test="${var.gender == 1 }">
												男
											</c:when>
											<c:otherwise>
												女
											</c:otherwise>
										</c:choose>
									</td>
									<td>${var.memberAge}</td>
									<td>${var.scan_quantity}</td>
									<td><fmt:formatDate value="${var.first_scan_time}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
									<td>
										<c:choose>
											<c:when test="${var.follow_state == 1 }">
												<font color="green">关注</font>
											</c:when>
											<c:otherwise>
												<font color="red">未关注</font>
											</c:otherwise>
										</c:choose>
									</td>
							</tr>
						</c:forEach>
						<!-- 
						<tr>
							<td colspan="100" class="center">您无权查看</td>
						</tr>
						 -->
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
			</table>
			<div style="color: red;">注:消息推送只会推送当前处于关注状态的用户，未关注状态的用户将不被推送！</div>
		<div class="page-header position-relative">
		<table style="width:100%;">
			<tr>
				<td style="vertical-align: top;">
					<a title="推送全部" class="btn btn-small btn-success" onclick="has(3,'','');">消息推送(全部)</a>
					<a title="批量推送" class="btn btn-small btn-success" onclick="has(2,'','确定要给选中的关注用户推送消息吗?');">消息推送(选中批量)</a>
					<a title="用户数据导出" class="btn btn-small btn-success" onclick="exportExcel();">用户数据导出</a>
				</td>
				<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
			</tr>
		</table>
		</div>
		</form>
	</div>
 
	<!-- PAGE CONTENT ENDS HERE -->
	
</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
		
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="static/js/bootstrap.min.js"></script>
		<script src="static/js/ace-elements.min.js"></script>
		<script src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<!-- 引入 -->
		
		<script type="text/javascript">
		$(top.hangge());
		//检索
		function search(){
			top.jzts();
			$("#Form").submit();
		}
		
		//查看
		function view(Id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="查看";
			 diag.URL = '<%=basePath%>/members/goView.do?m_id='+Id;
			 diag.Width = 400;
			 diag.Height = 435;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none')
				 {
					 nextPage(${page.currentPage});
				 }
				diag.close();
			 };
			 diag.show();
		};
		</script>
		
		<script type="text/javascript">
		
		//导出excel
		function toExcel(){
			window.location.href='<%=basePath%>/favoriteMembers/excel.do';
		}
		
		//复选框
		$('table th input:checkbox').on('click' , function(){
			var that = this;
			$(this).closest('table').find('tr > td:first-child input:checkbox')
			.each(function(){
				this.checked = that.checked;
				$(this).closest('tr').toggleClass('selected');
			});
				
		});
		
		
		function showAllDataViaGender(gender){
			var age = $("#age").val();
			var scanQuantity = $("#scanQuantity").val();
			window.location.href='<%=basePath%>/favoriteMembers/list.do?gender=' + gender+ '&age=' + age + '&scanQuantity=' + scanQuantity;
		}
		
		function showAllDataViaAge(age){
			if(age==0){
				age='';
			}
			var gender = $("#gender").val();
			var scanQuantity = $("#scanQuantity").val();
			window.location.href='<%=basePath%>/favoriteMembers/list.do?age=' + age + '&gender=' + gender + '&scanQuantity=' + scanQuantity;
		}
		
		function showAllDataViaScanQuantity(scanQuantity){
			if(scanQuantity==0){
				scanQuantity='';
			}
			var gender = $("#gender").val();
			var age = $("#age").val();
			window.location.href='<%=basePath%>/favoriteMembers/list.do?scanQuantity=' + scanQuantity + '&gender=' + gender + '&age=' + age;
		}
		
		//判断编码是否存在
		function has(pushSope, Id, msg){
			if(pushSope == 1){
				push(Id);
			}else if(pushSope == 2){
				makeAll(msg);
			}else{
				pushAll();
			}
		}
		
		//推送选中的
		function makeAll(msg){
			bootbox.confirm(msg, function(result) {
				if(result) {
					var str = '';
					var emstr = '';
					var phones = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++){
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  	
						  	if(emstr=='') emstr += document.getElementsByName('ids')[i].id;
						  	else emstr += ';' + document.getElementsByName('ids')[i].id;
						  	
						  	if(phones=='') phones += document.getElementsByName('ids')[i].alt;
						  	else phones += ';' + document.getElementsByName('ids')[i].alt;
						  }
					}
					if(str==''){
						bootbox.dialog("您没有选择任何内容!", 
							[
							  {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback": function() {
									//Example.show("great success");
									}
								}
							 ]
						);
						
						$("#zcheckbox").tips({
							side:3,
				            msg:'点这里全选',
				            bg:'#AE81FF',
				            time:8
				        });
						
						return;
					}else{
						top.jzts();
					 	var diag = new top.Dialog();
					 	diag.Drag=true;
						diag.Title ="消息推送";
						diag.URL = 'organfavoritemsgpush/pushOrganFavoriteMsg.do?m_ids=' + str + '&pushScope=2&message_type=1';
						diag.Width = 670;
						diag.Height = 660;
						diag.CancelEvent = function(){ //关闭事件
							if('${page.currentPage}' == '0'){
								top.jzts();
								setTimeout("self.location=self.location",100);
							}else{
								nextPage(${page.currentPage});
							}
							diag.close();
						};
						diag.show();
					}
				}
			});
		}
		
		//推送全部
		function pushAll(){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="消息推送";
			 diag.URL = '<%=basePath%>/organfavoritemsgpush/pushOrganFavoriteMsg.do?pushScope=3&message_type=1';
			 diag.Width = 670;
			 diag.Height = 660;
			 diag.CancelEvent = function(){ //关闭事件
				 if('${page.currentPage}' == '0'){
					 top.jzts();
					 setTimeout("self.location=self.location",100);
				 }else{
					 nextPage(${page.currentPage});
				 }
				diag.close();
			 };
			 diag.show();
		}
		
		function exportExcel(){
			var status = $("#status").val();
			var gender = $("#gender").val();
			var age = $("#age").val();
			var scanQuantity = $("#scanQuantity").val();
			window.location.href='<%=basePath%>/favoriteMembers/exportExcel.do?gender='+gender+'&age='+age+'&status='+status+'&scanQuantity='+scanQuantity;
		}
		</script>
	</body>
</html>

